package com.gbx.ximalayating.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gbx.ximalayating.R;
import com.gbx.ximalayating.adapter.FindViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;


public class FindFragment extends Fragment {
    private ViewPager pager;
    private String[] titles=new String[]{"推荐","分类","广播","榜单","主播"};
    private List<Fragment> fragments;

    public FindFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_find, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        fragments=new ArrayList<>();
        fragments.add(new RecommendFragment());
        fragments.add(new ClassifyFragment());
        fragments.add(new BroadcastFragment());
        fragments.add(new MonthlyFocusFragment());
        fragments.add(new AnchorFragment());
        pager = (ViewPager)view.findViewById(R.id.find_pager);
        pager.setOffscreenPageLimit(4);
        pager.setAdapter(new FindViewPagerAdapter(getFragmentManager(),titles,fragments));
        TabLayout tabLayout = (TabLayout) view.findViewById(R.id.find_top_tab);
        tabLayout.setupWithViewPager(pager);

    }
}
